from setting import *
from enemyplane import *
class EnemyUnit(pygame.sprite.Sprite):
    def __init__(self):
        self._layer = 2
        self.groups = allgroup, enemygroup
        pygame.sprite.Sprite.__init__(self, self.groups)
        self.image = pygame.image.load('./images/enemy/enemy0.png')
        self.rect = self.image.get_rect()
        self.interval = 1000
        self.unitnumber = 0
        self.start_time = pygame.time.get_ticks()
        self.set_pos(-300,-300)

    def set_pos(self,x,y):
        self.rect.x = x
        self.rect.y = y

    def update(self):
        cur_time = pygame.time.get_ticks()
        if cur_time - self.start_time < self.interval:
            return
        self.start_time = cur_time
        enemy = EnemyPlane()
        enemy.set_path()
        enemy.set_pos(-10,-10)
        self.unitnumber  +=1
        if self.unitnumber > 6:
            self.kill()
